package com.shiguiwu.springmybatis.designpattern.iterator;

import lombok.extern.slf4j.Slf4j;

/**
 * @description: 迭代器模式
 * @author: stone
 * @date: Created by 2021/9/7 10:34
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.iterator
 */
@Slf4j
public class IteratorTests {

    public static void main(String[] args) {
        GroupStructure g = new GroupStructure("1", "石贵武");
        g.add(new Employee("2", "爱豆", "二级部门"));
        g.add(new Employee("3", "旺旺", "二级部门"));
        g.add(new Employee("4", "小花", "三级部门"));
        g.add(new Employee("5", "小流", "三级部门"));
        g.add(new Employee("6", "小明", "四级部门"));
        g.add(new Employee("7", "牛牛", "四级部门"));
        g.add(new Employee("8", "二狗子", "四级部门"));
        //部门初始化完毕
        g.addLink("1", new Link("1","2"));
        g.addLink("1", new Link("1","3"));
        g.addLink("2", new Link("2","4"));
        g.addLink("2", new Link("2","5"));
        g.addLink("5", new Link("5","6"));
        g.addLink("5", new Link("5","7"));
        g.addLink("5", new Link("5","8"));

        Iterator<Employee> iterate = g.iterate();

        while (iterate.hasNext()) {
            Employee next = iterate.next();
            log.info("{}，雇员 Id：{} Name：{}", next.getDescription(),
                    next.getUserId(), next.getName());
        }

    }
}
